package com.sdhs.projectstart.controller;

import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.core.page.TableDataInfo;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.projectstart.domain.ProjectDesign;
import com.sdhs.projectstart.service.IProjectDesignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目联合设计信息操作处理
 *
 * @author ww
 */
@RestController
@RequestMapping("/projectStart/design")
public class ProjectDesignController extends BaseController {
    @Autowired
    private IProjectDesignService projectDesignService;

    /**
     * 查询项目联合设计列表
     */
    @PreAuthorize("@ss.hasPermi('projectStart:design:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectDesign projectDesign) {
        startPage();
        List<ProjectDesign> list = projectDesignService.selectProjectDesignList(projectDesign);
        return getDataTable(list);
    }

    /**
     * 获取项目进度控制--联合设计详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectStart:design:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(projectDesignService.selectProjectDesignById(id));
    }
    /**
     * 新增项目联合设计
     */
    @PreAuthorize("@ss.hasPermi('projectStart:design:add')")
    @Log(title = "项目联合设计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectDesign projectDesign) {
        return success(projectDesignService.insertProjectDesign(projectDesign));
    }

    /**
     * 修改项目联合设计
     */
    @PreAuthorize("@ss.hasPermi('projectStart:design:edit')")
    @Log(title = "项目联合设计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectDesign projectDesign) {
        return toAjax(projectDesignService.updateProjectDesign(projectDesign));
    }

    /**
     * 删除项目联合设计
     */
    @PreAuthorize("@ss.hasPermi('projectStart:design:remove')")
    @Log(title = "项目联合设计", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(projectDesignService.deleteProjectDesignByIds(ids));
    }
}
